﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace cmdb.keede.entity.Migrations
{
    public partial class UpdatePicUserReference : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_APPLICAT_REFERENCE_USER",
                table: "ApplicationInfo");

            migrationBuilder.DropIndex(
                name: "IX_ApplicationInfo_PIC",
                table: "ApplicationInfo");

            migrationBuilder.RenameColumn(
                name: "PIC",
                table: "ApplicationInfo",
                newName: "PICName");

            migrationBuilder.AddColumn<string>(
                name: "PICId",
                table: "ApplicationInfo",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_ApplicationInfo_PICId",
                table: "ApplicationInfo",
                column: "PICId");

            migrationBuilder.AddForeignKey(
                name: "FK_APPLICAT_REFERENCE_USER",
                table: "ApplicationInfo",
                column: "PICId",
                principalTable: "User",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_APPLICAT_REFERENCE_USER",
                table: "ApplicationInfo");

            migrationBuilder.DropIndex(
                name: "IX_ApplicationInfo_PICId",
                table: "ApplicationInfo");

            migrationBuilder.DropColumn(
                name: "PICId",
                table: "ApplicationInfo");

            migrationBuilder.RenameColumn(
                name: "PICName",
                table: "ApplicationInfo",
                newName: "PIC");

            migrationBuilder.CreateIndex(
                name: "IX_ApplicationInfo_PIC",
                table: "ApplicationInfo",
                column: "PIC");

            migrationBuilder.AddForeignKey(
                name: "FK_APPLICAT_REFERENCE_USER",
                table: "ApplicationInfo",
                column: "PIC",
                principalTable: "User",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
